#include "includes.h"
#include <unistd.h>
#include <ctime>
//only for debugging, will not be needed in the final build:
#include <iostream>

#include <string>
#include <pthread.h>
using namespace std;

Input* input;
int x=0, y=0;
void *play(void *iinterface){
	Interface *interface=(Interface*)iinterface;
	while (false){
		/*input=interface->default_screen->get_input();
		if (input!=NULL && input->type==INP_KEY){
			switch (((Input_key*)input)->key){
				case 'd':
					interface->default_screen->add_widget(Widget_unit('d', x, y++));
					break;
				case 'a':
					interface->default_screen->add_widget(Widget_unit('a', x++, y));
					break;
			}
		}*/
		interface->blit();
		usleep(100000);
	}
	usleep(100000);
	return NULL;
};
int main(int argc, char * argv[]){
	Interface* interface= new Interface();
//	Screen* screen= new Screen();
	#ifndef NO_SCREEN
	interface->default_screen->add_widget(Widget_unit('F', 15, 5));
	interface->default_screen->add_widget(Widget_building("Evil construction yard"));
	#endif
	interface->handle(new Input_key((int)'a', false, true, true));
	interface->handle(new Action_update(0, 1, 1));
	//time_t program_end=time(NULL)+10;
	interface->blit();
/*	pthread_t thread;
	void** result;
	pthread_create(&thread, NULL, play, (void*)interface);
	pthread_join(thread, result);*/
	cout << "Program exit." <<endl;
	delete interface;
	return 0;
};
